package com.ruibang.glass.purchase.feign;

import com.ruibang.glass.common.domain.file.FileBusiness;
import com.ruibang.glass.common.domain.file.FileInfo;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@FeignClient("glass-file")
@Component
public interface FileApi {

    @RequestMapping(value = "/api/glass/file/updateBusinessById", method = RequestMethod.POST)
    ResultBody updateBusinessById(@RequestBody FileBusiness fileBusiness);

    @RequestMapping(value = "/api/glass/file/uploadFile", consumes = "multipart/form-data", method = RequestMethod.POST)
    ResultBody uploadFile(@RequestPart("files") MultipartFile files);

    @RequestMapping(value = "/api/glass/file/deleteByFileIds", method = RequestMethod.POST)
    ResultBody deleteByFileIds(@RequestBody List<String> fileIds);

    @RequestMapping(value = "/api/glass/file/deleteByBusinessId/{businessId}", method = RequestMethod.GET)
    ResultBody deleteByBusinessId(@PathVariable("businessId") String businessId);


    @RequestMapping(value = "/api/glass/file/deleteByBusinessIdAndAttribute", method = RequestMethod.POST)
    ResultBody deleteByBusinessIdAndAttribute(@RequestBody FileBusiness fileBusiness);


    @RequestMapping(value = "/api/glass/file/getFileIdsByBusinessId/{businessId}", method = RequestMethod.GET)
    ResultBody<List<String>> getFileIdsByBusinessId(@PathVariable("businessId") String businessId);


    @RequestMapping(value = "/api/glass/file/getFileBusinessByIds", method = RequestMethod.POST)
    ResultBody<List<FileBusiness>> getFileBusinessByIds(@RequestBody List<String> businessIds);

    @RequestMapping(value = "/api/glass/file/downloadFile/{id}", method = RequestMethod.GET)
    void downloadFile(@PathVariable("id") String id);

    @RequestMapping(value = "/api/glass/file/previewFiles", method = RequestMethod.POST)
    ResultBody previewFiles(@RequestBody FileBusiness fileBusiness);

    @PostMapping("/api/glass/file/getFileInfoByFileIds")
    @ApiOperation(value = "根据fileId批量获取获取文件信息", notes = "根据fileId批量获取获取文件信息")
    ResultBody<List<FileInfo>> getFileInfoByFileIds(@RequestBody List<String> fileIds);

    @PostMapping(value = "/api/glass/file/save")
    @ApiOperation(value = "保存文件信息", notes = "保存文件信息")
    ResultBody saveInfo(@RequestBody List<FileInfo> files);

    @PostMapping("/api/glass/file/getPreviewByBusinessParam")
    @ApiOperation(value = "根据参数查询文件信息", notes = "根据参数查询文件信息")
    ResultBody<List<String>> getPreviewByBusinessParam(@RequestBody FileBusiness fileBusiness);


}
